package modelLayer;

import java.util.ArrayList;
import java.util.List;

public class TeacherCon {
	private static TeacherCon instance;
	private List<Teacher> teachers;
	
	private TeacherCon(){
		teachers = new ArrayList<>();
	}
	
	public static TeacherCon getInstance(){
		if (instance == null){
			instance = new TeacherCon();
		}
		return instance;
	}
	
	public boolean addTeacher(Teacher t){
		return teachers.add(t);
	}
	
	public boolean removeTeacher(Teacher t){
		boolean found = false;
		for (int i = 0; i < teachers.size() && !found; i ++){
			if (teachers.get(i).equals(t)){
				found = teachers.remove(teachers.get(i));
			}
		}
		return found;
	}
	
	public Teacher findTeacher(String name){
		boolean found = false;
		Teacher t = null;
		for (int i = 0; i < teachers.size() && !found; i ++){
			if (teachers.get(i).getName().equalsIgnoreCase(name)){
				t = teachers.get(i);
			}
		}
		return t;
	}

	/**
	 * @return the teachers
	 */
	public List<Teacher> getTeachers() {
		return teachers;
	}

	/**
	 * @param teachers the teachers to set
	 */
	public void setTeachers(List<Teacher> teachers) {
		this.teachers = teachers;
	}
	
	
	
}
